package webapp.mvc.models;

import com.zoowii.jpa_utils.extension.ExtendFinder;
import com.zoowii.jpa_utils.orm.Model;
import webapp.mvc.enums.IntBooleans;
import webapp.mvc.utils.IdGenerator;
import webapp.mvc.utils.TimeUtil;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.sql.Timestamp;

@Entity
@Table(name = "captcha_request")
public class CaptchaRequestEntity extends Model {
    public static final ExtendFinder<String, CaptchaRequestEntity> find = new ExtendFinder<>(String.class, CaptchaRequestEntity.class);

    private String id = IdGenerator.nextId();
    private int version = 1;
    private Timestamp createdTime = TimeUtil.currentTimestamp();
    private int expireSeconds = 60;
    private int deleted = IntBooleans.FALSE;
    private String answer;

    @Id
    @Column(name = "id", nullable = false)
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Column(name = "version", nullable = false)
    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    @Column(name = "create_time", nullable = false)
    public Timestamp getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Timestamp createdTime) {
        this.createdTime = createdTime;
    }

    @Column(name = "expire_seconds", nullable = false)
    public int getExpireSeconds() {
        return expireSeconds;
    }

    public void setExpireSeconds(int expireSeconds) {
        this.expireSeconds = expireSeconds;
    }

    @Column(name = "deleted", nullable = false)
    public int getDeleted() {
        return deleted;
    }

    public void setDeleted(int deleted) {
        this.deleted = deleted;
    }

    @Column(name = "answer", nullable = false)
    public String getAnswer() {
        return answer;
    }

    public void setAnswer(String answer) {
        this.answer = answer;
    }
}